<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html"; charset="UTF-8">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <title>复选框全选</title>
    <script type="text/javascript">
        $(function () {
         //全选按钮的单击事件
            $("#selectall").click(function () {
                //获取selectall这个复选框的checked是否选中属性，并赋值给所有name叫做cb的复选框
                $("[name='cb']").prop("checked",$("#selectall").prop("checked"));
            });
        });
    </script>
</head>
<body>
    <table border="1" width="800px">
        <tr>
            <td><input type="checkbox" id="selectall">全选</td>
            <td>id</td>
            <td>姓名</td>
            <td>年龄</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="cb"></td>
            <td>1</td>
            <td>青龙</td>
            <td>18</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="cb"></td>
            <td>2</td>
            <td>白虎</td>
            <td>200</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="cb"></td>
            <td>3</td>
            <td>朱雀</td>
            <td>30</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="cb"></td>
            <td>4</td>
            <td>玄武</td>
            <td>50</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="cb"></td>
            <td>5</td>
            <td>饕餮</td>
            <td>60</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="cb"></td>
            <td>6</td>
            <td>梼杌</td>
            <td>79</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="cb"></td>
            <td>7</td>
            <td>穷奇</td>
            <td>45</td>
        </tr>
        <tr>
            <td><input type="checkbox" name="cb"></td>
            <td>8/td>
            <td>混沌</td>
            <td>96</td>
        </tr>
    </table>
</body>
</html>